import { apiRequest } from "./request.js";

const host = `oxsywjoh.http01.cn/learningplatform`; //服务器主机域名
export const httpBaseUrl = `http://${host}`; //HTTP请求服务器基本地址
export const wsBaseUrl = `wss://shitukj.cn/service/websocket`; //WebSocket请求服务器基本地址

// mock
// 获取作品列表
export const getWorkList = (requestConfig) =>
    apiRequest("mockApi/test", { method: "GET", requestConfig });
// 获取常看作者
export const getAuthorList = (requestConfig) =>
    apiRequest("mockApi/authorList", { method: "GET", requestConfig });
// 获取动态列表
export const getTrendList = (requestConfig) =>
    apiRequest("mockApi/trendsList", { method: "GET", requestConfig });

//用户登录
export const login = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/login`, { method: "POST", requestConfig });

//用户注册
export const register = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/register`, { method: "POST", requestConfig });

//发帖
export const postDiscuss = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/discuss/add`, { method: "POST", requestConfig });

//查看帖子列表
export const getDiscussList = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/index`, { method: "GET", requestConfig });

//查看图片
export const getImage = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/upload/:imagename`, { method: "GET", requestConfig });

//帖子详情页
export const discussDetail = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/discuss/detail/${requestConfig.urlParam}`, { method: "GET", requestConfig });

//帖子总数
export const discussCount = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/rows?faculty=0`, { method: "GET", requestConfig });

//点赞
export const like = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/like`, { method: "POST", requestConfig });


//评论总数
export const commentCount = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/discuss/CommentCount/:discussPostId`, { method: "GET", requestConfig });

//评论
export const comment = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/comment/add/${requestConfig.urlParam}`, { method: "POST", requestConfig });


//搜索
export const search = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/search?keyword=好&page=1&limit=10`, { method: "GET", requestConfig });

//用户
//查看用户信息
export const getUser = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/profile/:userId`, { method: "GET", requestConfig });

//退出登录
export const logout = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/logout`, { method: "GET", requestConfig });

//修改密码
export const updatePassword = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/update`, { method: "POST", requestConfig });


//消息
//私信列表
export const letterList = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/letter/list?page=1&limit=10`, { method: "GET", requestConfig });

//私信详情页
export const letterDetail = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/letter/detail/:conversationId?page=1&limit=10`, { method: "GET", requestConfig });

//发送私信
export const sendLetter = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/letter/send?toName=1940706150&content=Hello!`, { method: "POST", requestConfig });

//通知列表
export const noticeList = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/notice/list`, { method: "GET", requestConfig });

//查看系统消息
export const getNoticeDetail = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/notice/detail/:topic?page=1&limit=10`, { method: "GET", requestConfig });

//食途登录
export const loginTest = (requestConfig) =>
    apiRequest(`https://shitukj.cn/service/login`, { method: "POST", requestConfig });
//获取目录上传签名
export const getUploadSignature = (requestConfig) =>
    apiRequest(`https://shitukj.cn/service/signature-oss`, { method: "GET", requestConfig });

//获取我的私信列表
export const getMyChatList = (requestConfig) =>
    apiRequest(`https://shitukj.cn/service/chat/list`, { method: "GET", requestConfig });

//获取私信记录
export const getChatHistory = (requestConfig) =>
    apiRequest(`https://shitukj.cn/service/chat/user/${requestConfig.urlParam}`, { method: "GET", requestConfig });
//发送私信

export const sendMessage = (requestConfig) =>
    apiRequest(`https://shitukj.cn/service/chat/user/${requestConfig.urlParam}`, { method: "POST", requestConfig });
//删除私信记录
export const deleteChatHistory = (requestConfig) =>
    apiRequest(`https://shitukj.cn/service/chat/${requestConfig.urlParam}`, { method: "DELETE", requestConfig });
//删除私信列表中的私信记录
export const deleteChatWithFriend = (requestConfig) =>
    apiRequest(`https://shitukj.cn/service/chat/friend/${requestConfig.urlParam}`, { method: "DELETE", requestConfig });
//获取登录websocket的令牌
export const getUserToken = (requestConfig) =>
    apiRequest(`https://shitukj.cn/service/socket/connection`, { method: "GET", requestConfig });